#ifndef __MAIN_H__
#define __MAIN_H__

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

#define THREAD_PRIORITY 1
#define THREAD_STACK_SIZE 512
#define THREAD_TIMESLICE 10

#ifdef __cplusplus
extern "C"
{
#endif

    enum
    {
        MOTOR_INDEX_1,
        MOTOR_INDEX_2,
    };

    struct balance_info
    {
        float power;
        float balanceKp;
        float balanceKd;
        float velocityKp;
        float velocityKi;
    };

    struct balance_control
    {
        rt_uint8_t forward : 1;
        rt_uint8_t backward : 1;
        rt_uint8_t left : 1;
        rt_uint8_t right : 1;
        rt_int32_t speed;
    };

    struct vector_3d
    {
        float x;
        float y;
        float z;
    };

    extern struct balance_info info;

    void set_motor_pwm(rt_int32_t index, rt_int32_t pwm);

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H__ */